<template>
  <div class="box">
    <van-card v-for="item in newlist" :key="item.id" @click='run(item.id)'>
      <div slot="thumb" style="width:100%;height:100%" class="image">
        <img :src="item.img_url" style="width:42px;height:42px" />
      </div>
      <div slot="desc" style="width:100%;height:17px;overflow: hidden;">
        <h3>{{item.title}}</h3>
      </div>
      <div slot="tags">
        <div type="danger" class="tag-l">发布时间：{{item.add_time.slice(0,10)}}</div>
        <div plain type="danger" class="tag-r">点击：{{item.click}}</div>
      </div>
    </van-card>
    
  </div>
</template>
<script>
import { mapMutations } from "vuex"
export default {
  data() {
    return {
      // 新闻资讯列表
      newlist: [],
     
    };
  },
  created() {
    this.getNewlist();
  },
  methods: {
      ...mapMutations(["setNewsId"]),
    //   获取数据
    async getNewlist() {
      const { data: res } = await this.$axios.get("/api/getnewslist");
      console.log(res.message);
      this.newlist = res.message;
    },
    run(id){
      this.setNewsId(id)
        console.log(id);
     this.$router.push('/news/detail/'+id) 
    }
  }
};
</script>
<style scoped lang="less">
</style>